import axios from 'axios'

const Mock = require('mockjs')
const Random = Mock.Random

Random.extend({
  phone: function () {
    var phonePrefixs = ['132', '135', '189'] // 自己写前缀哈
    return this.pick(phonePrefixs) + Mock.mock(/\d{8}/) //Number()
  }
})

// 会员列表
Mock.mock('/api/getUserList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.increment(),
      avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
      mobile: Random.phone(),
      nickname: Random.cname(),
      openNum: Random.integer(1, 1000),
      integral: Random.integer(1, 1000),
      loginTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      recentPayTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      platform: Random.pick([1, 2]),
      registerWay: Random.pick([1, 2, 3, 4, 5]),
      createdTime: Random.date('yyyy-MM-dd')
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 会员详情
Mock.mock('/api/getUserInfo', () => {
  return {
    data: {
      id: Random.increment(),
      avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
      mobile: Random.phone(),
      nickname: Random.cname(),
      openNum: Random.integer(1, 1000),
      loginTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      platform: Random.pick([1, 2]),
      recentPayTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      registerWay: Random.pick([1, 2, 3, 4, 5]),
      createdTime: Random.date('yyyy-MM-dd'),
      isNew: Random.boolean()
    }
  }
})

// 积分明细列表
Mock.mock('/api/getIntegralList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.increment(),
      integral: Random.integer(1, 1000),
      integralType: Random.pick([1, 2]),
      accountBalance: Random.integer(1, 1000),
      remark: Random.cword(5, 10),
      platform: Random.pick([1, 2]),
      time: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 积分兑换明细列表
Mock.mock('/api/getIntegraConvertlList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.increment(),
      integralOrigin: Random.pick([1, 2]),
      integral: Random.integer(1, 1000),
      relevancyOrder: Random.character('lower'),
      accountSatus: Random.pick([1, 2]),
      accountIntegral: Random.integer(1, 1000),
      getTime: Random.date('yyyy-MM-dd hh:mm'),
      accountTime: Random.date('yyyy-MM-dd hh:mm')
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 待审核企业主列表
Mock.mock('/api/getAuditlList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.increment(),
      avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
      nickname: Random.cname(),
      mobile: Random.phone(),
      companyNmae: Random.cword(5, 10),
      businessLicenseCode: Random.string('number', 12),
      businessLicense: Random.image('80x40', '#50B347', '#FFF', 'Mock.js'),
      applyTime: Random.date('yyyy-MM-dd hh:mm'),
      auditStatus: Random.pick([1, 2]),
      failInfo: {
        failCause: Random.cword(10, 20),
        operator: Random.cname(),
        handleTime: Random.date('yyyy-MM-dd hh:mm')
      }
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 已入驻企业主列表
Mock.mock('/api/getEnterlList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.increment(),
      avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
      nickname: Random.cname(),
      mobile: Random.phone(),
      companyNmae: Random.cword(5, 10),
      businessLicenseCode: Random.string('number', 12),
      integralBalance: Random.integer(1, 1000),
      makeInvoiceLogs: Random.pick([1, 2]),
      relevancyClient: Random.integer(1, 1000),
      enterTime: Random.date('yyyy-MM-dd hh:mm'),
      auditStatus: Random.pick([1, 2]),
      isFreeze: Random.boolean()
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 企业主充值记录列表
Mock.mock('/api/getReplenisList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      orderId: Random.id(),
      figure: Random.float(1, 2000, 0, 2),
      integral: Random.integer(1, 1000),
      giveIntegral: Random.integer(0, 10),
      payType: Random.pick([1, 2]),
      handler: Random.cname(),
      mobile: Random.phone(),
      isInvoice: Random.pick([1, 2, 3]),
      accountStatus: Random.pick([1, 2]),
      time: Random.date('yyyy-MM-dd hh:mm')
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 企业主赠送记录列表
Mock.mock('/api/getGiveList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.guid(),
      integral: Random.integer(1, 1000),
      payType: Random.pick([1, 2, 3]),
      accountStatus: Random.pick([1, 2, 3]),
      giveTime: Random.date('yyyy-MM-dd hh:mm'),
      userInfo: Random.pick([
        null,
        {
          avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
          nickname: Random.cname(),
          mobile: Random.phone()
        }
      ]),
      remark: Random.cword(0, 15)
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 企业主开票记录列表
Mock.mock('/api/getInvoiceList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.guid(),
      avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
      nickname: Random.cname(),
      mobile: Random.phone(),
      invoiceHead: Random.cword(5, 10),
      dutyParagraph: Random.string('number', 11),
      figure: Random.integer(1, 1000),
      email: Random.email(),
      bankInfo: {
        name: Random.cword(5, 10),
        cardNo: Random.string('number', 11)
      },
      registerAddress: Random.county(true),
      orderNo: Random.string('number', 11),
      invoiceType: Random.pick([1, 2]),
      applyTime: Random.date('yyyy-MM-dd hh:mm'),
      evidence: Random.pick([
        'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ])
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 企业主关联列表
Mock.mock('/api/getRelevancyClientList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.guid(),
      integral: Random.integer(1, 1000),
      creadTime: Random.date('yyyy-MM-dd hh:mm'),
      userInfo: {
        avatar: Random.image('60x60', '#50B347', '#FFF', 'Mock.js'),
        nickname: Random.cname(),
        mobile: Random.phone()
      }
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

// 积分套餐列表
Mock.mock('/api/getIntegralMealList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.guid(),
      integral: Random.integer(1, 1000),
      integralGive: Random.integer(1, 1000),
      figure: Random.integer(1, 1000),
      sort: Random.integer(1, 1000),
      isOpen: Random.boolean(),
      creadTime: Random.date('yyyy-MM-dd hh:mm')
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(1, 20)
  }
})

export function getUserList() {
  return axios.get('/api/getUserList')
}

export function getUserInfo() {
  return axios.get('/api/getUserInfo')
}

export function getIntegralList() {
  return axios.get('/api/getIntegralList')
}

export function getIntegraConvertlList() {
  return axios.get('/api/getIntegraConvertlList')
}

export function getAuditlList() {
  return axios.get('/api/getAuditlList')
}

export function getEnterlList() {
  return axios.get('/api/getEnterlList')
}

export function getReplenisList() {
  return axios.get('/api/getReplenisList')
}

export function getGiveList() {
  return axios.get('/api/getGiveList')
}

export function getInvoiceList() {
  return axios.get('/api/getInvoiceList')
}

export function getRelevancyClientList() {
  return axios.get('/api/getRelevancyClientList')
}

export function getIntegralMealList() {
  return axios.get('/api/getIntegralMealList')
}
